package builderpattern;

import java.util.ArrayList;
import java.util.List;
/**
 * 建造者模式--饭订单类
 * MealOrder.java
 * @author yaojinshan
 * @since 2017年5月24日 下午3:21:37
 *
 */
public class MealOrder{

	private List<MealItem> mealList = new ArrayList<>();
	
	public void addMealItem(MealItem mi){
		mealList.add(mi);
	}
	/**
	 * 获取总价格
	 * @return
	 */
	public void getCost(){
		float cost = 0f;
		for(MealItem mi : mealList){
			cost += mi.price();
		}
		System.out.println("cost:" + cost);
	}
	/**
	 * 展示菜单内容
	 */
	public void showOrder(){
		for(MealItem mi : mealList){
			System.out.println("price:" + mi.price() + ",mealname:" + mi.mealName() + ",packType:" + mi.packType().pack());
		}
	}
}
